home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / JDBC / JDBC_011 / JAVA / SQL / SQLWARNI.JAV < prev    next >
Encoding:
Text File  |  1996-11-10  |  3.8 KB  |  117 lines

  1. /*
  2.  * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software
  5.  * and its documentation for NON-COMMERCIAL purposes and without
  6.  * fee is hereby granted provided that this copyright notice
  7.  * appears in all copies. Please refer to the file "LICENSE"
  8.  * for further important copyright and licensing information.
  9.  *
  10.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  11.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  12.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  13.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  14.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  15.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  16.  * 
  17.  * THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE
  18.  * CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE
  19.  * PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT
  20.  * NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE
  21.  * SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE
  22.  * SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE
  23.  * PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES").  SUN
  24.  * SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR
  25.  * HIGH RISK ACTIVITIES.
  26.  */
  27.  
  28. package java.sql;
  29.  
  30. /**
  31.  * <P>The SQLWarning class provides information on a database access
  32.  * warnings. Warnings are silently chained to the object whose method
  33.  * caused it to be reported.
  34.  *
  35.  * @see Connection#getWarnings
  36.  * @see Statement#getWarnings
  37.  * @see ResultSet#getWarnings 
  38.  */
  39. public class SQLWarning extends SQLException {
  40.  
  41.     /**
  42.      * Construct a fully specified SQLWarning.
  43.      *
  44.      * @param reason a description of the warning 
  45.      * @param SQLState an XOPEN code identifying the warning
  46.      * @param vendorCode a database vendor specific warning code
  47.      */
  48.      public SQLWarning(String reason, String SQLstate, int vendorCode) {
  49.     super(reason, SQLstate, vendorCode);
  50.     DriverManager.println("SQLWarning: reason(" + reason + 
  51.                   ") SQLstate(" + SQLstate + 
  52.                   ") vendor code(" + vendorCode + ")");
  53.     }
  54.  
  55.  
  56.     /**
  57.      * Construct an SQLWarning with a reason and SQLState;
  58.      * vendorCode defaults to 0.
  59.      *
  60.      * @param reason a description of the warning 
  61.      * @param SQLState an XOPEN code identifying the warning
  62.      */
  63.     public SQLWarning(String reason, String SQLstate) {
  64.     super(reason, SQLstate);
  65.     DriverManager.println("SQLWarning: reason(" + reason + 
  66.                   ") SQLState(" + SQLstate + ")");
  67.     }
  68.  
  69.     /**
  70.      * Construct an SQLWarning with a reason; SQLState defaults to
  71.      * null and vendorCode defaults to 0.
  72.      *
  73.      * @param reason a description of the warning 
  74.      */
  75.     public SQLWarning(String reason) {
  76.     super(reason);
  77.     DriverManager.println("SQLWarning: reason(" + reason + ")");
  78.     }
  79.  
  80.     /**
  81.      * Construct an SQLWarning ; reason defaults to null, SQLState
  82.      * defaults to null and vendorCode defaults to 0.
  83.      *
  84.      */
  85.     public SQLWarning() {
  86.     super();
  87.     DriverManager.println("SQLWarning: ");
  88.     }
  89.  
  90.  
  91.     /**
  92.      * Get the warning chained to this one
  93.      *
  94.      * @return the next SQLException in the chain, null if none
  95.      */
  96.     public SQLWarning getNextWarning() {
  97.     try {
  98.         return ((SQLWarning)getNextException());
  99.     } catch (ClassCastException ex) {
  100.         // The chained value isn't a SQLWarning.
  101.         // This is a programming error by whoever added it to
  102.         // the SQLWarning chain.  We throw a Java "Error".
  103.         throw new Error("SQLWarning chain holds value that is not a SQLWarning");
  104.     }
  105.     }
  106.  
  107.     /**
  108.      * Add an SQLWarning to the end of the chain.
  109.      *
  110.      * @param w the new end of the SQLException chain
  111.      */
  112.     public void setNextWarning(SQLWarning w) {
  113.     setNextException(w);
  114.     }
  115.  
  116. }
  117.